home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / SQLWarning.java < prev    next >
Text File  |  1998-09-22  |  3KB  |  104 lines

  1. /*
  2.  * @(#)SQLWarning.java    1.6 98/07/01
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  * 
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.sql;
  16.  
  17. /**
  18.  * <P>The SQLWarning class provides information on a database access
  19.  * warnings. Warnings are silently chained to the object whose method
  20.  * caused it to be reported.
  21.  *
  22.  * @see Connection#getWarnings
  23.  * @see Statement#getWarnings
  24.  * @see ResultSet#getWarnings 
  25.  */
  26. public class SQLWarning extends SQLException {
  27.  
  28.     /**
  29.      * Construct a fully specified SQLWarning.
  30.      *
  31.      * @param reason a description of the warning 
  32.      * @param SQLState an XOPEN code identifying the warning
  33.      * @param vendorCode a database vendor specific warning code
  34.      */
  35.      public SQLWarning(String reason, String SQLstate, int vendorCode) {
  36.     super(reason, SQLstate, vendorCode);
  37.     DriverManager.println("SQLWarning: reason(" + reason + 
  38.                   ") SQLstate(" + SQLstate + 
  39.                   ") vendor code(" + vendorCode + ")");
  40.     }
  41.  
  42.  
  43.     /**
  44.      * Construct an SQLWarning with a reason and SQLState;
  45.      * vendorCode defaults to 0.
  46.      *
  47.      * @param reason a description of the warning 
  48.      * @param SQLState an XOPEN code identifying the warning
  49.      */
  50.     public SQLWarning(String reason, String SQLstate) {
  51.     super(reason, SQLstate);
  52.     DriverManager.println("SQLWarning: reason(" + reason + 
  53.                   ") SQLState(" + SQLstate + ")");
  54.     }
  55.  
  56.     /**
  57.      * Construct an SQLWarning with a reason; SQLState defaults to
  58.      * null and vendorCode defaults to 0.
  59.      *
  60.      * @param reason a description of the warning 
  61.      */
  62.     public SQLWarning(String reason) {
  63.     super(reason);
  64.     DriverManager.println("SQLWarning: reason(" + reason + ")");
  65.     }
  66.  
  67.     /**
  68.      * Construct an SQLWarning ; reason defaults to null, SQLState
  69.      * defaults to null and vendorCode defaults to 0.
  70.      *
  71.      */
  72.     public SQLWarning() {
  73.     super();
  74.     DriverManager.println("SQLWarning: ");
  75.     }
  76.  
  77.  
  78.     /**
  79.      * Get the warning chained to this one
  80.      *
  81.      * @return the next SQLException in the chain, null if none
  82.      */
  83.     public SQLWarning getNextWarning() {
  84.     try {
  85.         return ((SQLWarning)getNextException());
  86.     } catch (ClassCastException ex) {
  87.         // The chained value isn't a SQLWarning.
  88.         // This is a programming error by whoever added it to
  89.         // the SQLWarning chain.  We throw a Java "Error".
  90.         throw new Error("SQLWarning chain holds value that is not a SQLWarning");
  91.     }
  92.     }
  93.  
  94.     /**
  95.      * Add an SQLWarning to the end of the chain.
  96.      *
  97.      * @param w the new end of the SQLException chain
  98.      */
  99.     public void setNextWarning(SQLWarning w) {
  100.     setNextException(w);
  101.     }
  102.  
  103. }
  104.